package com.ciaojian.client.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ciaojian.core.model.ChargeLog;
import com.ciaojian.core.service.ChargeLogService;
import org.springframework.stereotype.Service;

/**
 * @author oxiny
 */
@Service
public class ChargeLogServiceImpl extends ChargeLogService {
    /**
     * 分页查询充值记录
     *
     * @param userId 用户ID
     * @param page   分页插件
     * @return /
     */
    public IPage<ChargeLog> pageCharge(Integer userId, Page<ChargeLog> page) {
        return this.lambdaQuery()
                .select(ChargeLog::getId,
                        ChargeLog::getUserId,
                        ChargeLog::getChargeId,
                        ChargeLog::getPrice,
                        ChargeLog::getAddTime,
                        ChargeLog::getTargetId)
                .eq(ChargeLog::getUserId, userId)
                .eq(ChargeLog::getTargetType, 0)
                .orderByDesc(ChargeLog::getAddTime)
                .page(page);
    }
}
